package com.joysuch.wwyt.core.enums;

/**
 * @Author ZhangDong
 * @Date 2020/9/17 16:58
 */
public enum UserRoleTypes {

    EMPLOYEEE(0, "员工"),
    MANAGER(1, "管理人员"),
    COMPANY_CHARGER(2, "企业负责人");

    private Integer index;
    private String roleName;

    UserRoleTypes(Integer index, String roleName) {
        this.index = index;
        this.roleName = roleName;
    }

    public Integer getIndex() {
        return index;
    }

    public String getRoleName() {
        return roleName;
    }

    public static String getRoleNameByIndex(Integer index) {
        UserRoleTypes[] values = UserRoleTypes.values();
        for (UserRoleTypes value : values) {
            if (value.getIndex().equals(index)) {
                return value.roleName;
            }
        }
        return null;
    }

    public static Integer getRoleIndexByName(String name) {
        if(name == null) {
            return null;
        }
        UserRoleTypes[] values = UserRoleTypes.values();
        for (UserRoleTypes value : values) {
            if (value.getRoleName().equals(name)) {
                return value.index;
            }
        }
        return null;
    }

}
